﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace EfCoreDemo.Data.Migrations
{
    public partial class addCertificationOnResumeWithDeleteV2 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Certification_UserResumes_ResumeId",
                table: "Certification");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Certification",
                table: "Certification");

            migrationBuilder.RenameTable(
                name: "Certification",
                newName: "Certifications");

            migrationBuilder.RenameIndex(
                name: "IX_Certification_ResumeId",
                table: "Certifications",
                newName: "IX_Certifications_ResumeId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Certifications",
                table: "Certifications",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Certifications_UserResumes_ResumeId",
                table: "Certifications",
                column: "ResumeId",
                principalTable: "UserResumes",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Certifications_UserResumes_ResumeId",
                table: "Certifications");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Certifications",
                table: "Certifications");

            migrationBuilder.RenameTable(
                name: "Certifications",
                newName: "Certification");

            migrationBuilder.RenameIndex(
                name: "IX_Certifications_ResumeId",
                table: "Certification",
                newName: "IX_Certification_ResumeId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Certification",
                table: "Certification",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Certification_UserResumes_ResumeId",
                table: "Certification",
                column: "ResumeId",
                principalTable: "UserResumes",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
